using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class LiftBehaviour
{
    public float LiftingSpeed { get; set; }


    public LiftBehaviour()
    {
    }

    public abstract void LiftUp(LiftBehaviourParam param, float startTime = 0);
}
public class LiftMoveByStaticSpeedBehaviour : LiftBehaviour
{
    public LiftMoveByStaticSpeedBehaviour() : base()
    {

    }

    public override void LiftUp(LiftBehaviourParam param, float startTime = 0)
    {
        param.Lift.transform.localPosition = Vector3.MoveTowards(param.Lift.transform.localPosition, new Vector3(param.Lift.transform.localPosition.x, param.end * param.Lift.transform.localScale.y, param.Lift.transform.localPosition.z), param.liftSpeed * Time.deltaTime * param.Lift.transform.localScale.y);
        LiftingSpeed = param.liftSpeed * param.Lift.transform.localScale.y;
    }
}

public class LiftMoveByStaticTimeBehaviour : LiftBehaviour
{
    public LiftMoveByStaticTimeBehaviour() : base()
    {

    }
    public override void LiftUp(LiftBehaviourParam param, float startTime = 0)
    {
        float lerpValueY = Mathf.Lerp(param.current, param.end, (param.timer - startTime) / param.routeTime);
        param.Lift.transform.localPosition = new(param.Lift.transform.localPosition.x, lerpValueY, param.Lift.transform.localPosition.z);
        LiftingSpeed = Mathf.Abs(param.current - param.end) / param.routeTime;
    }
}

public class LiftBehaviourParam
{
    public LiftBehaviourParam()
    {

    }

    public LiftBehaviourParam(Transform Lift, float current, float end, float routeTime, float timer, float liftSpeed)
    {
        this.Lift = Lift;
        this.current = current;
        this.end = end;
        this.routeTime = routeTime;
        this.timer = timer;
        this.liftSpeed = liftSpeed;
    }
    public LiftBehaviourParam(Transform Lift, float current, float end, float routeTime, float timer)
    {
        this.Lift = Lift;
        this.current = current;
        this.end = end;
        this.routeTime = routeTime;
        this.timer = timer;
    }
    public LiftBehaviourParam(Transform Lift, float liftSpeed, float current, float end)
    {
        this.Lift = Lift;
        this.current = current;
        this.end = end;
        this.liftSpeed = liftSpeed;
    }

    public Transform Lift { get; private set; }
    public float current { get; private set; }
    public float end { get; private set; }
    public float routeTime { get; private set; }
    public float timer { get; private set; }
    public float liftSpeed { get; private set; }
}